﻿@using WB.Core.SharedKernels.SurveyManagement.Web.Models
@using WB.UI.Headquarters.Services
@using WB.Core.BoundedContexts.Headquarters.Resources
@using WB.Infrastructure.Native.Workspaces
@inject IWorkspaceContextAccessor workspaceContext

@{
    var page = ViewBag.ActivePage ?? MenuItem.Logon;

    var workspace = workspaceContext.CurrentWorkspace();
    var isSystemWorkspace = workspace?.IsSystemDefinedWorkspace() ?? false;
    if (isSystemWorkspace)
    {
        var workspaces = (IEnumerable<WorkspaceContext>)ViewData["UserWorkspacesList"];
        workspace = workspaces.FirstOrDefault();
    }
}
<ul class="nav navbar-nav" role="menu">
    <li class="dropdown @(page == MenuItem.SurveyAndStatuses || page == MenuItem.Summary || page == MenuItem.Statuses ? "active" : "")">
        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" title="@MainMenu.Reports">
            @MainMenu.Reports <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
            @Html.MainMenuItem(workspace, "SurveysAndStatusesForSv", "Reports", @MainMenu.SurveysAndStatuses, MenuItem.SurveyAndStatuses)
            @Html.MainMenuItem(workspace, "TeamMembersAndStatuses", "Reports", @MainMenu.TeamMembersAndStatuses, MenuItem.Summary)
            @Html.MainMenuItem(workspace, "TeamStatusDuration", "Reports", @MainMenu.StatusDuration, MenuItem.StatusDuration)
            @Html.MainMenuItem(workspace, "QuantityByInterviewers", "Reports", @MainMenu.Quantity, MenuItem.NumberOfCompletedInterviews)
            @Html.MainMenuItem(workspace, "SpeedByInterviewers", "Reports", @MainMenu.Speed, MenuItem.SpeedOfCompletingInterviews)
            @Html.MainMenuItem(workspace, "MapReport", "Reports", @MainMenu.MapReport, MenuItem.MapReport)
            @Html.MainMenuItem(workspace, "SurveyStatistics", "Reports", @MainMenu.SurveyStatistics, MenuItem.SurveyStatistics)
        </ul>
    </li>

    @Html.MainMenuItem(workspace, "Index", "Interviews", MainMenu.Interviews, MenuItem.Interviews)
    @Html.MainMenuItem(workspace, "Interviewers", "Users", MainMenu.TeamAndRoles, MenuItem.Interviewers)
    
    <li class="dropdown  @(page == MenuItem.Assignments || page == MenuItem.Maps ? "active" : "")">
            <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" title="@MainMenu.SurveySetup">
                @MainMenu.SurveySetup <span class="caret"></span>
            </a>
            <ul class="dropdown-menu">
                @Html.MainMenuItem("Index", "Assignments", @MainMenu.Assignments, MenuItem.Assignments)
                @Html.MainMenuItem("Index", "Maps", @MainMenu.Maps, MenuItem.Maps)
            </ul>
    </li>

</ul>
<ul class="nav navbar-nav navbar-right" role="menu">
    <li>
        <a href="https://docs.mysurvey.solutions/headquarters" target="_blank" class="icon-link" title="@MainMenu.Help">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="icon" viewBox="0 0 16 16">
                <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
                <path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/>
            </svg>
        </a>
    </li>
    <li class="dropdown @(page == MenuItem.ManageAccount ? "active" : "")">
        <a href="javascript:void(0);" class="dropdown-toggle toggle-sized" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"
           title="@User.Identity.Name">
            @User.Identity.Name<span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
            <li>@Html.ActionLink(Common.DownloadSupervisor, "Supervisor", "Download", new { area = string.Empty }, null)</li>
            @Html.MainMenuItem(workspace, "Manage", "Users", Strings.SurverManagement_MainMenu_ManageAccount, MenuItem.ManageAccount)
            <li>
                <a href="/Account/LogOff">@Common.Logoff</a>
            </li>
        </ul>
    </li>
</ul>
